Skip to content

Conversation

egonSchiele
Copy link
Owner

Output:

contracts.ruby (adit/215) $ cat test.rb
require "contracts"
include Contracts

Contract Num => Num
def incr x
  "Sdf"
end

incr(23)
contracts.ruby (adit/215) $ ruby test.rb
/Users/abhargava/contracts.ruby/lib/contracts.rb:45:in `block in <class:Contract>': Contract violation for return value: (ReturnContractError)
        Expected: Num,
        Actual: "Sdf"
        Value guarded in: Object::incr
        With Contract: Num => Num
        All arguments: [23]
        At: test.rb:5
    from /Users/abhargava/contracts.ruby/lib/contracts.rb:155:in `call'
    from /Users/abhargava/contracts.ruby/lib/contracts.rb:155:in `failure_callback'
    from /Users/abhargava/contracts.ruby/lib/contracts/call_with.rb:82:in `call_with'
    from /Users/abhargava/contracts.ruby/lib/contracts/method_handler.rb:138:in `block in redefine_method'
    from test.rb:9:in `<main>'

cc @waterlink @beezee (for issue #215)

@egonSchiele
Copy link
Owner Author

Oh man, I forgot I need to update the output in the Cucumber tests :/

@waterlink
Copy link
Collaborator

This is a very useful feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants